 package com.jcrj.dao.imp;
 
 import java.sql.SQLException;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.jcrj.dao.UserDao;
import com.jcrj.entity.ORoleUser;
import com.jcrj.entity.OUser;
 
 public class UserDaoImp extends AbstractBaseDaoImp
   implements UserDao
 {
   public OUser getUser(final String name, final String password)
   {
     String hql = "from  OUser u where u.del='0' and u.status='0' and u.account=? and u.psw=?";
     return (OUser)getHibernateTemplate().execute(new HibernateCallback()
     {
       public Object doInHibernate(Session session) throws HibernateException, SQLException
       {
         Query query = session.createQuery("from  OUser u where u.del='0' and u.status='0' and u.account=? and u.psw=?");
         query.setString(0, name);
         query.setString(1, password);
         return query.uniqueResult();
       }
     });
   }
 
   public void saveUser(OUser user)
   {
     getHibernateTemplate().save(user);
   }
 
   public void deleteUser(OUser user)
   {
     getHibernateTemplate().delete(user);
   }
 
   public void updateUser(OUser user)
   {
     getHibernateTemplate().update(user);
   }
 
   public void saveUserRole(ORoleUser roleUser) {
     getHibernateTemplate().save(roleUser);
   }
 }